package cn.gdut.chengcai.enums;

import org.apache.commons.lang.StringUtils;

/**
 * 会员状态
 *
 * @author gates
 *
 */
public enum MemberStatus {
	UNKNOWNED(0), // 未知
	WAIT_ACTIVATE(1), // 待激活
	NORMAL(5), // 正常
	WAIT_AUTH(11), // 待认证
	WAIT_AUTH_AUDIT(12), // 待认证审核
	AUTH_AUDIT_FAIL(13), // 认证审核失败
	WAIT_DELETE_AUDIT(21), // 待删除审核
	DELETE_AUDIT_FAIL(22), // 删除审核失败
	WAIT_DELETE(91), // 待删除
	DELETED(99); // 已删除

	private int value;

	private MemberStatus(int value) {
		this.value = value;
	}

	public int getValue() {
		return value;
	}

	public String getString() {
		return getString(this.value);
	}

	public static String getString(Integer value) {
		String result = "未知";
		if (StringUtils.isEmpty(value.toString()) == true) {
			return result;
		}
		if (value == MemberStatus.WAIT_ACTIVATE.getValue()) {
			result = "账号待激活";
		} else if (value == MemberStatus.NORMAL.getValue()) {
			result = "正常";
		} else if (value == MemberStatus.WAIT_AUTH.getValue()) {
			result = "待认证";
		} else if (value == MemberStatus.WAIT_AUTH_AUDIT.getValue()) {
			result = "待认证审核";
		} else if (value == MemberStatus.AUTH_AUDIT_FAIL.getValue()) {
			result = "认证审核失败";
		} else if (value == MemberStatus.WAIT_DELETE_AUDIT.getValue()) {
			result = "待删除审核";
		} else if (value == MemberStatus.DELETE_AUDIT_FAIL.getValue()) {
			result = "删除审核失败";
		} else if (value == MemberStatus.WAIT_DELETE.getValue()) {
			result = "待删除";
		} else if (value == MemberStatus.DELETED.getValue()) {
			result = "已删除";
		}
		return result;
	}

	public static Integer getInteger(String value) {
		Integer result = 0;
		if (value.equals("待激活")) {
			result = MemberStatus.WAIT_ACTIVATE.getValue();
		} else if (value.equals("正常")) {
			result = MemberStatus.NORMAL.getValue();
		} else if (value.equals("待认证")) {
			result = MemberStatus.WAIT_AUTH.getValue();
		} else if (value.equals("待认证审核")) {
			result = MemberStatus.WAIT_AUTH_AUDIT.getValue();
		} else if (value.equals("认证审核失败")) {
			result = MemberStatus.AUTH_AUDIT_FAIL.getValue();
		} else if (value.equals("待删除审核")) {
			result = MemberStatus.WAIT_DELETE_AUDIT.getValue();
		} else if (value.equals("删除审核失败")) {
			result = MemberStatus.DELETE_AUDIT_FAIL.getValue();
		} else if (value.equals("待删除")) {
			result = MemberStatus.WAIT_DELETE.getValue();
		} else if (value.equals("已删除")) {
			result = MemberStatus.DELETED.getValue();
		}
		return result;
	}
}